package com.gcsj.gcsjspringboot.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.gcsj.gcsjspringboot.entity.SysMenuEntity;
import com.gcsj.gcsjspringboot.entity.SysRoleMenuEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 角色与菜单对应关系
 *
 * @author
 */
@Mapper
public interface SysRoleMenuDao extends BaseMapper<SysRoleMenuEntity> {

	/**
	 * 根据角色ID，获取菜单ID列表
	 */
	List<Long> queryMenuIdList(Long roleId);
	@Select("select d.* from sys_role_menu b, sys_menu d\n" +
			"where b.role_id in (select role_id from sys_user_role a\n" +
			"where a.user_id = #{userId}) and b.menu_id = d.menu_id")
	List<SysMenuEntity> queryMenuList(Long userId);

	/**
	 * 根据角色ID数组，批量删除
	 */
	int deleteBatch(Long[] roleIds);
}
